import { Injectable } from '@angular/core';
import {AuthorService} from "./author.service";
import {LoggerService} from "./logger.service"
@Injectable()
class UserService {
  constructor(private _logger:LoggerService, private author:boolean) {
    this._logger.log('user service init')
  }
  getuser(){
    if(this.author){
      this._logger.log('允许获取')
      return {name:'star'}
    }else{
      this._logger.log('不可获取');
      return null;
    }
  }
}

//工厂方法，参数是服务引入，内部实例化服务，传递服务实例，会调用cconstructor。
//返回实例
let UserServiceProvider = (logger:LoggerService,authorize: AuthorService) => {
    return new UserService(logger, authorize.getIsAuthorized());
};
export {UserServiceProvider,UserService}
